This invention relates to computer graphics systems and, more particularly, to methods and apparatus for full scene anti-aliasing in texture mapping computer graphics systems.
Computer graphics systems are used for displaying graphical representations of objects on a two-dimensional display screen. In a typical computer graphics system, an object to be represented on a display screen is broken down into multiple graphics primitives. Primitives are basic components of a graphics image and may include points, lines, vectors and polygons, such as triangles. Typically, a hardware/software scheme is implemented to render, or draw, on the two-dimensional display screen, the graphics primitives that represent a view of one or more objects being represented on the screen.
Typically, the primitives that define the three-dimensional object to be rendered are provided from a host computer, which defines each primitive in terms of primitive data. For example, when the primitive is a triangle, the host computer may define the primitive in terms of the X,Y,Z coordinates of its vertices, as well as the R,G,B color values of each vertex. Rendering hardware interpolates the primitive data to compute the display screen pixels that represent each primitive, and the R,G,B values for each pixel.
Aliasing is an effect that occurs in computer graphics systems because of the discrete nature of the pixels that make up a graphics display. An example of aliasing is the jagged edges in the graphics display of polygons that should in fact have smooth edges. The jagged edges result from a rendering process wherein each pixel is determined to be inside or outside the polygon.
Prior art anti-aliasing techniques include scene anti-aliasing and polygon anti-aliasing. True scene anti-aliasing involves supersampling of each pixel being rendered. A filter is applied to the supersampled area to remove aliasing artifacts, effectively smoothing out jagged edges. The entire image being rendered is anti-aliased. Polygon anti-aliasing applies anti-aliasing filters to the edges of polygons to smooth out their edges. Non-polygonal primitives are not anti-aliased unless another primitive specific filtering technique is utilized.
Texture mapping is commonly used in computer graphics systems to provide improved surface detail. Texture mapping involves mapping a source image, referred to as a texture, onto a surface of a three-dimensional object, and thereafter mapping the textured three-dimensional object to the two-dimensional display screen. The texture mapping involves applying one or more point elements (texels) of a texture to each point element (pixel) of the displayed portion of the object to which the texture is being mapped. Texture mapping hardware is conventionally provided with information indicating the manner in which the texels in a texture map correspond to the pixels on the display screen that represent the object. Each texel in a texture map is defined by S and T coordinates which identify its location in the two-dimensional texture map. In the case of a three-dimensional texture map, each texel is defined by S, T and R coordinates. For each pixel, the corresponding texel or texels that map to it are accessed from the texture map and are incorporated into the final R,G,B values generated for the pixel to represent the textured object on the display screen.
Each pixel in an object primitive may not map in a one-to-one correspondence with a single texel in the texture map. Depending on the size of the object on the display screen and the size of the texture map, a single pixel may map to multiple texels, or a single texel may map to multiple pixels. To facilitate texture mapping, a series of MIP maps may be created for each texture. A series of MIP maps includes a base map that corresponds directly to the texture map and a series of filtered maps, wherein each successive map is reduced in size by a factor of two in each of the two texture map dimensions. The series of texture MIP maps associated with the object being rendered is stored in a local memory accessible by the texture mapping hardware.
The texture mapping hardware can access texture data from any of the series of MIP maps. The determination of which map to access to provide the texel data for any particular pixel is based on the number of texels to which the pixel maps. If a pixel maps in a one-to-one correspondence with a single texel in the texture map, then the base map is accessed. However, if the pixel maps to 4, 16 or 64 texels, then different level maps in the series are accessed because those maps store texel data representing an average of 4, 16 and 64 texels in the texture map.
A pixel may not map directly to any one texel in the selected map and may fall between two or more texels in a single map or may fall between two maps. In this case, interpolation is utilized to accurately produce texel data. The texel data corresponding to a pixel can be a weighted average of four texel entries in a single map or a weighted average of eight texels in the two closest maps.
It is desirable to provide anti-aliasing in texture mapping computer graphics systems. The anti-aliasing functionality should be provided with a minimum of additional hardware and should use existing functionality to the extent possible
According to a first aspect of the invention, a method is provided for performing scene anti-aliasing in a computer graphics system comprising a rasterizer, a texture mapping subsystem and a frame buffer. The method comprises steps of defining a supersample image buffer and a single sample image buffer, using the rasterizer to render a supersampled image to the supersample image buffer, and using the texture mapping subsystem to downsample the supersampled image to the single sample image buffer, wherein the downsampled image in the single sample image buffer is anti-aliased.
Preferably, the supersample image buffer and the single sample image buffer are allocated in the frame buffer. The image buffers may be allocated by pseudo-linear frame buffer mapping.
The computer graphics systems preferably utilizes a double buffer configuration, including a first buffer for rendering and a second buffer for display. The first and second buffers are swapped following completion of rendering and display of an image. The step of downsampling the supersampled image to the single sample image buffer is preferably performed at the time of double buffer swap.
The downsampling operation may comprise a four to one downsampling operation, such as a bilinear interpolation. In one embodiment, the downsampling operation is a single operation for each pixel. In another embodiment, the downsampling operation comprises a first downsampling operation to provide an intermediate image and a second downsampling operation of the intermediate image to provide a final downsampled image.
According to another aspect of the invention, apparatus is provided for performing scene anti-aliasing in a computer graphics system comprising a rasterizer, a texture mapping subsystem and a frame buffer. The apparatus comprises means for defining a supersample image buffer and a single sample image buffer, means for using the rasterizer to render a supersampled image to the supersample image buffer, and means for using the texture mapping subsystem to downsample the supersampled image to the single sample image buffer, wherein the downsampled image in the single sample image buffer is anti-aliased.
According to a further aspect of the invention, apparatus is provided for scene anti-aliasing in a computer graphics system. The apparatus comprises a frame buffer containing a supersample image buffer for storing a supersampled image and a single sample image buffer for storing a downsampled image, a rasterizer for rendering a supersampled image to the supersample image buffer in response to information defining an image, and a texture mapping subsystem for downsampling the supersampled image to the single sample image buffer. The downsampled image in the single sample image buffer constitutes an anti-aliased image.